var chuanzhiid="";
txkui.parse();
let index = 2;
var rightmenushow = true;
// new Date('2014-04-23').getTime()
// new Date('2014-03-21').getTime()
// console.log(Date123);
// console.log(123);

var gestInfo= new Array();
function getGestWeeksNbc(){
    //获取引产时间
    var childbirthDate=mini.get("childbirthDate").value; //引产时间
    if( childbirthDate == null || childbirthDate == "")
        return;
    date1 = childbirthDate;

    //获取末次月经时间
    var dia=mini.get("#diacrisisId").value;
    for(var i=0;i<gestInfo.length;i++){
        if(dia==gestInfo[i].diacrisisId){
            date2 = gestInfo[i].lastMenses;
            break;
        }
    }
    if((date1 == null || date1 == "") || (date2== null || date2== ""))
        return;
    getNumberOfDays(date1,date2,2);
}
function  getGestWeeksChild(){

    //获取出生时间
    var nbcBirthday=mini.get("nbcBirthday").value;  //出生时间
    var date1=null,date2=null;

    if(nbcBirthday == null || nbcBirthday == "")
        return;
    date1 = nbcBirthday;

    //获取末次月经时间
    var dia=mini.get("#diacrisisId").value;
    for(var i=0;i<gestInfo.length;i++){
        if(dia==gestInfo[i].diacrisisId){
            date2 = gestInfo[i].lastMenses;
            break;
        }
    }
    if((date1 == null || date1 == "") || (date2== null || date2== ""))
        return;
    getNumberOfDays(date1,date2,1);
}

//出生日期计算
function getNumberOfDays(date1,date2,type){//获得天数
    // date1：开始日期，date2结束日期
    var a1 = Date.parse(new Date(date1));
    var a2 = Date.parse(new Date(date2));
    // var day = parseInt((a2-a1)/ (1000 * 60 * 60 * 24));//核心：时间戳相减，然后除以天数
    var day = parseInt((a2-a1)/ (1000 * 60 * 60 * 24));//核心：时间戳相减，然后除以天数

    let gestWeeks=Math.floor(day/7);
    let  gestDays=day%7;

    if(type==1){
        mini.get("gestWeeks").setValue(gestWeeks);
        mini.get("gestDays").setValue(gestDays);
    }
    if(type==2){
        mini.get("inducedGestWeeks").setValue(gestWeeks);
        mini.get("inducedGestWeeks").setValue(gestDays);
    }
};

$('.zdmenubuttom').click(function() {
    if (rightmenushow) {
        $('.rightmenu').animate({
            width: 'toggle'
        }, 350);
        rightmenushow = false;
        $('.zdmenubuttom').children("img").attr("src","../../img/show.png");
    } else {
        $('.rightmenu').animate({
            width: 'toggle'
        }, 350);
        $('.zdmenubuttom').children("img").attr("src","../../img/hide.png");
        rightmenushow = true;
    }
})
// function calRange(dom1, dom2, dom3){
//
//             var startDate = $(dom1).val(), endDate = $(dom2).val();
//               if(startDate.length > 0 && endDate.length > 0){
//                     var start_date = new Date(startDate);
//                       var end_date = new Date(endDate);
//                       var days = (end_date - start_date)/86400000;
//                       $(dom3).text(days + "天");
//                  } else {
//                        $(dom3).text(0 + "天");
//                }
//           }

// function datedifference(sDate1, sDate2) {    //sDate1和sDate2是2006-12-18格式  
//     var dateSpan,
//         tempDate,
//         iDays;
//     sDate1 = Date.parse(sDate1);
//     sDate2 = Date.parse(sDate2);
//     dateSpan = sDate2 - sDate1;
//     dateSpan = Math.abs(dateSpan);
//     iDays = Math.floor(dateSpan / (24 * 3600 * 1000));
//     return iDays
//     console.log(iDays)
// };
$(function(){
    //右侧随访登记加载
    $.ajax({
        type: "POST",
        dataType: "json",
        url:  SVR_PATH+"cqzd/do/diacinfo/queryDiacrisisInfo",
        data: {
            'key': '1',
            "isValid": '1'
        },
        success: function(result) {
            var ghlist = result;
            gestInfo=result.data;
            $('.xinruguahao').append($("#user").tmpl(ghlist));
        }
    });

    //右侧历史随访
    $.ajax({
        type: "POST",
        dataType: "json",
        url:  SVR_PATH+"cqzd/do/flupinfo/queryListByKey",
        data: {
            'key': '1'
        },
        success: function(result) {
            var ghlist = result;
            $('.lishiguahao').append($("#lishiuser").tmpl(ghlist));
        },
    });

    var id = getQueryString("patientCardId");
    if(id){
        $(".thisrightselect").val(id);
        //右侧随访登记加载
        $.ajax({
            type: "POST",
            dataType: "json",
            url:  SVR_PATH+"cqzd/do/diacinfo/queryDiacrisisInfo",
            data: {
                'key':id
            },
            success: function(result) {

                if(result.data.length){
                    $(".zhezhao").fadeOut(1000);
                    var tabs = mini.get("tabs1");
                    var tab = tabs.getTabs();
                    for(var i = tab.length-1;i>=0;i--){

                        tabs.removeTab(tab[i]);
                    }
                    index = 1;
                    testAdd();
                    patientId = result.data[0].diacrisisId;
                    patientName = result.data[0].patientName;
                    chuanzhiid="";
                    var form = new mini.Form("#SFXXGLform");
                    form.clear();
                    var patient=mini.get("#patientName");
                    var diacrisisId=mini.get("#diacrisisId");
                    patient.setValue(patientName);
                    diacrisisId.setValue(patientId);
                }
            }
        });
        //右侧历史随访
        $.ajax({
            type: "POST",
            dataType: "json",
            url:  SVR_PATH+"cqzd/do/flupinfo/queryListByKey",
            data: {
                'key': id
            },
            success: function(result) {
                if(result.data.length){
                    patientId = result.data[0].diacrisisId;
                    patientName = result.data[0].patientName;
                    $(".zhezhao").fadeOut(1000);
                    //清空tab页
                    var tabs = mini.get("tabs1");
                    var tab = tabs.getTabs();
                    for(var i = tab.length-1;i>=0;i--){

                        tabs.removeTab(tab[i]);
                    }
                    index = 1;
                    var userid = $(el).children('.thisuserid').html();
                    chuanzhiid=userid;
                    binliFlupId=userid;
                    HttpUtil.get(SVR_PATH+"cqzd/do/flupinfo/queryFlupByDiacrisisId?diacrisisId=" + patientId,function(result) {
                        for(var i = 0; i < result.data.length; i++){

                            testAdd(function () {
                                var tabBodyEl = tabs.getTabBodyEl(tab[i]);
                                if (result.data[i].isSpecKeep === '1') {
                                    $(tabBodyEl).find('#specKeepId').css('display', 'block');
                                } else{
                                    $(tabBodyEl).find('#specKeepId').css('display', 'none');
                                    $(tabBodyEl).find('#specKeepId').val("");
                                }
                                var model = result.data[i];
                                for(var j in model){
                                    // $(tabBodyEl).find("[name = '"+j+"']").val(model[j]);
                                    //var obj=mini.getbyName(j,tabBodyEl);
                                    var obj=mini.getbyName(j,tabBodyEl);
                                    if(obj){
                                        obj.setValue(model[j]);
                                    }
                                }
                            });
                        }
                    });
                }
            },
        });
    }
})

var binliFlupId="";
var patientName = -1;
var patientId = -1;
//右侧菜单点击
function rightuserclick(el) {
    $(".userclick").removeClass("userclick");
    $(el).addClass("userclick");
    $(".zhezhao").fadeOut(1000);
    var tabs = mini.get("tabs1");
    var tab = tabs.getTabs();
    for(var i = tab.length-1;i>=0;i--){

        tabs.removeTab(tab[i]);
    }
    index = 1;
    testAdd();
    patientId = $(el).children('.thisuserid').html();
    patientName = $(el).find('.thisusername').html();
    chuanzhiid="";
    var form = new mini.Form("#SFXXGLform");
    form.clear();
    var patient=mini.get("#patientName");
    var diacrisisId=mini.get("#diacrisisId");
    patient.setValue(patientName);
    diacrisisId.setValue(patientId);
}

function rightlishiclick(el){
    patientId = $(el).children('.thisuserid').html();
    patientName = $(el).find('.thisusername').html();
    $(".userclick").removeClass("userclick");
    $(el).addClass("userclick");
    $(".zhezhao").fadeOut(1000);
    //清空tab页
    var tabs = mini.get("tabs1");
    var tab = tabs.getTabs();
    for(var i = tab.length-1;i>=0;i--){

        tabs.removeTab(tab[i]);
    }
    index = 1;
    var userid = $(el).children('.thisuserid').html();
    chuanzhiid=userid;
    binliFlupId=userid;
    HttpUtil.get(SVR_PATH+"cqzd/do/flupinfo/queryFlupByDiacrisisId?diacrisisId=" + userid,function(result) {
        // testAdd();
        // var tabBodyEl = tabs.getTabBodyEl(tab[i])
        // for(var j in result.data.flupAndDiacModel){
        //     var obj = mini.getByName(j,tabBodyEl);
        //     if(obj){
        //         obj.setValue(result.data.flupAndDiacModel[j])
        //     }
        // }


        for(var i = 0; i < result.data.length; i++){

            testAdd(function () {
                var tabBodyEl = tabs.getTabBodyEl(tab[i])
                if (result.data[i].isSpecKeep === '1') {
                    $(tabBodyEl).find('#specKeepId').css('display', 'block');
                } else{
                    $(tabBodyEl).find('#specKeepId').css('display', 'none');
                    $(tabBodyEl).find('#specKeepId').val("")
                }
                var model = result.data[i];
                for(var j in model){
                    // $(tabBodyEl).find("[name = '"+j+"']").val(model[j]);
                    var obj = nui.getbyName(j,tabBodyEl);
                    if(obj){
                        obj.setValue(model[j]);
                    }
                }
            });
        }
        // patientName = result.data.flupAndDiacModel.patientName;
        // diacrisisId = result.data.flupAndDiacModel.diacrisisId;
        // if (result.data.flupAndDiacModel.isSpecKeep === '1') {
        //     $('#specKeepId').css('display', 'block');
        // } else{
        //     $('#specKeepId').css('display', 'none');
        //     mini.get("specKeepId").setValue("")
        // }
        //
        // var form = new mini.Form("#SFXXGLform");
        // console.log(result.data)
        // form.setData(result.data.flupAndDiacModel);
    });
}

//点击其他地方隐藏右侧
$(".bigdiv").click(function() {
    if (rightmenushow) {
        $('.rightmenu').animate({
            width: 'toggle'
        }, 350);
        rightmenushow = false;
    }
});

function submintSFXXGLform(){
    var loadingWin =mini.loading("请稍后...", "等待");
    var formData = new FormData();
    var form = new mini.Form("#SFXXGLform");
    form.validate();
    if (form.isValid() == false){
        mini.hideMessageBox(loadingWin);
        mini.alert("请完善您的数据");
        return;
    };
    // var biglist = form.getData();

    // console.log($(".HZXXGLContent")[0])
    for(var i = 0;i<$(".HZXXGLContent").length;i++){
        $($(".HZXXGLContent")[i]).find("input").each(function (object) {
            var objVal = this.value;
            var objName = this.name;
            if(objName===""){
            }else {
                formData.append("flupAndDiacModels["+i+"]."+objName,objVal);
            }
        })
        $($(".HZXXGLContent")[i]).find("textarea").each(function (object) {
            var objVal = this.value;
            var objName = this.name;
            if(objName===""){
            }else {
                formData.append("flupAndDiacModels["+i+"]."+objName,objVal);
            }
        })
        $($(".HZXXGLContent")[i]).find("#thisnibaba").each(function (object) {
            // console.log($(this))
            for(var j = 0;j<$(this)[0].files.length;j++){
                formData.append("flupAndDiacModels"+"["+i+"].files["+j+"]",$(this)[0].files[j]);
            }

        })
        // formData.append("json",JSON.stringify(flupAndDiacModel));
    }
    console.log(formData)
    $.ajax({
        url: SVR_PATH+"cqzd/do/flupinfo/updateFlupInfo",
        data: formData,
        type: "POST",
        processData: false,
        contentType: false,
        success: function(data) {
            mini.hideMessageBox(loadingWin);
            if(data.errMsg){
                mini.alert("新增失败,"+data.errMsg);
                return;
            }
            mini.alert("新增成功");

        },
        error: function(e) {
            mini.hideMessageBox(loadingWin);
            mini.alert("新增失败");
        }
    });
    // biglist.flupAndDiacModel.flupId=chuanzhiid;
    // biglist.flupAndDiacModel.isValid="1";
    // var fileArray=document.querySelector('#thisnibaba');

    // formData.append("json",JSON.stringify(modelList));
    // for(var i=0,f;f=fileArray.files[i];i++){
    //     formData.append("file", f);
    // }
    // if(chuanzhiid==""){
    //     $.ajax({
    //         url: SVR_PATH+"cqzd/do/flupinfo/addFlupInfo",
    //         data: formData,
    //         type: "POST",
    //         processData: false,
    //         contentType: false,
    //         success: function(data) {
    //             mini.hideMessageBox(loadingWin);
    //             if(data.errMsg){
    //                 mini.alert("新增失败,"+data.errMsg);
    //                 return;
    //             }
    //             mini.alert("新增成功");
    //
    //         },
    //         error: function(e) {
    //             mini.hideMessageBox(loadingWin);
    //             mini.alert("新增失败")
    //         }
    //     });
    // }
    // else{
    //     $.ajax({
    //         url: SVR_PATH+"cqzd/do/flupinfo/updateFlupInfo",
    //         data: formData,
    //         type: "POST",
    //         processData: false,
    //         contentType: false,
    //         success: function(data) {
    //             mini.hideMessageBox(loadingWin);
    //             if(data.errMsg){
    //                 mini.alert("修改失败,"+data.errMsg);
    //                 return;
    //             }
    //             mini.alert("修改成功");
    //         },
    //         error: function(e) {
    //             mini.hideMessageBox(loadingWin);
    //             mini.alert("修改失败")
    //         }
    //     });
    // }
}
function dropSFXXGLform(){
    var loadingWin =mini.loading("请稍后...", "等待");
    var form = new mini.Form("#SFXXGLform");
    var biglist = form.getData();
    biglist.flupAndDiacModel.flupId=chuanzhiid;
    biglist.flupAndDiacModel.isValid="2";
    var fileArray=document.querySelector('#thisnibaba');
    var formData = new FormData();
    formData.append("json",JSON.stringify(biglist));
    for(var i=0,f;f=fileArray.files[i];i++){
        formData.append("file", f);
    }

    $.ajax({
        url: SVR_PATH+"cqzd/do/flupinfo/updateFlupInfo",
        data: formData,
        type: "POST",
        processData: false,
        contentType: false,
        success: function(data) {
            mini.hideMessageBox(loadingWin);
            if(data.errMsg){
                mini.alert("作废失败,"+data.errMsg);
                return;
            }
            mini.alert("作废成功");
        },
        error: function(e) {
            mini.hideMessageBox(loadingWin);
            mini.alert("作废失败");
        }
    });
}
function renewSFXXGLform(){
    var loadingWin =mini.loading("请稍后...", "等待");
    var form = new mini.Form("#SFXXGLform");
    var biglist = form.getData();
    biglist.flupAndDiacModel.flupId=chuanzhiid;
    biglist.flupAndDiacModel.isValid="1";
    var fileArray=document.querySelector('#thisnibaba');
    var formData = new FormData();
    formData.append("json",JSON.stringify(biglist));
    for(var i=0,f;f=fileArray.files[i];i++){
        formData.append("file", f);
    }

    $.ajax({
        url: SVR_PATH+"cqzd/do/flupinfo/updateFlupInfo",
        data: formData,
        type: "POST",
        processData: false,
        contentType: false,
        success: function(data) {
            mini.hideMessageBox(loadingWin);
            if(data.errMsg){
                mini.alert("恢复失败,"+data.errMsg);
                return;
            }
            mini.alert("恢复成功");
        },
        error: function(e) {
            mini.hideMessageBox(loadingWin);
            mini.alert("恢复失败");
        }
    });
}
$('.righttitle').click(function() {
    $(this).next().animate({
        height: 'toggle'
    }, 350);
})

function changeselect(){
    var selectkey=$(".thisrightselect").val();
    var selectvalid = $('.zuofeicheck').is(':checked');
    var valid = 1;
    if (selectvalid) {
        valid = null;
    }
    loadrightlist(selectkey,valid);
}

function loadrightlist(selectkey,isValid){
    //右侧随访登记加载
    $.ajax({
        type: "POST",
        dataType: "json",
        url:  SVR_PATH+"cqzd/do/diacinfo/queryDiacrisisInfo",
        data: {
            'key':selectkey,
            "isValid": isValid
        },
        success: function(result) {
            var ghlist = result;
            for(var i=0;i<ghlist.data.length;i++){
                if(ghlist.data[i].isValid==="2"){
                    ghlist.data[i].isValid="isValid";
                }else{
                    ghlist.data[i].isValid="";
                }
            }
            $('.xinruguahao').empty();
            $('.xinruguahao').append($("#user").tmpl(ghlist));
        }
    });
    //右侧历史随访
    $.ajax({
        type: "POST",
        dataType: "json",
        url:  SVR_PATH+"cqzd/do/flupinfo/queryListByKey",
        data: {
            'key': selectkey,
            "isValid": isValid
        },
        success: function(result) {
            var ghlist = result;
            for(var i=0;i<ghlist.data.length;i++){
                if(ghlist.data[i].isValid==="2"){
                    ghlist.data[i].isValid="isValid";
                }else{
                    ghlist.data[i].isValid="";
                }
            }
            $('.lishiguahao').empty();
            $('.lishiguahao').append($("#lishiuser").tmpl(ghlist));
        },
    });
}

function valuechanged(that){
    if (this.getValue() === '1') {
        $(that.sender.el).parent().find("#specKeepId").css('display', 'block');
    } else{
        $(that.sender.el).parent().find("#specKeepId").css('display', 'none');
        mini.get("specKeepId").setValue("");
    }
}

// mini.get('isSpecKeep').on("valuechanged", function(e) {
//     if (this.getValue() === '1') {
//         $('#specKeepId').css('display', 'block');
//     } else{
//         $('#specKeepId').css('display', 'none');
//         mini.get("specKeepId").setValue("")
//     }
// });



//打开病例管理
function onclick4(that) {
    binliFlupId = $(that).parent().parent().parent().find("[name = 'flupId']").val();
    $(".tanchuang").css("display", "flex");
    loadwjxx(binliFlupId);
}
//关闭病例管理
function closeBLZL() {
    $(".tanchuang").css("display", "none");
}
//点击病例查询
function loadwjxx(binliFlupId) {
    $.ajax({
        type: "get",
        dataType: "json",
        url: SVR_PATH+"cqzd/do/flupfile/getFileByFkId/" + binliFlupId,
        data: {},
        success: function(result) {
            console.log(result);
            var files_grid = mini.get("files_grid");
            files_grid.setData(result.data);
        }
    });
}

//兵力管理里面的a标签
function onActionRenderer(e) {
    var row = e.row;
    var aa = row.fileName;
    var s = '<a href="'+SVR_PATH+'cqzd/do/flupfile/getFileByCode/' + row.fileCode + '">' + aa + '</a>';
    return s;

}

function testAdd(callback) {
    var tabs = mini.get("tabs1");

    //add tab
    var tab = {title: "随访记录"+index++};
    tab = tabs.addTab(tab);

    //tab body
    var el = tabs.getTabBodyEl(tab);
    $(el).append("<div class=\"bottontitle\">\n" +
        "                    <span>随访患者情况</span>\n" +
        "                </div>\n" +
        "                <div class=\"HZXXGLContent\">\n" +
        "                    <table>\n" +
        "                        <tr>\n" +
        "                            <td class=\"tabletitle\">就诊患者</td>\n" +
        "                            <td>" +
        "                           <input required=\"true\" allowInput=\"false\"  class=\"mini-textbox\" name=\"patientName\" id=\"patientName\" />" +
        "                           <input class=\"mini-textbox\" style=\"display: none;\" id=\"diacrisisId\" name=\"diacrisisId\" />" +
        "                           <input type=\"hidden\" class=\"mini-textbox\" id=\"flupId\" name=\"flupId\" style=\"display: none;\"></td>\n" +
        "                            <td class=\"tabletitle\">随访时间</td>\n" +
        "                            <td>" +
        "                            <input required=\"true\" id=\"statrDate\" class=\"mini-datepicker\" allowInput=\"false\" name=\"flupTime\" format=\"yyyy-MM-dd H:mm:ss\" timeFormat=\"H:mm:ss\" showTime=\"true\" />" +
        "                               </td>\n" +
        "                            <td class=\"tabletitle\">妊娠结局</td>\n" +
        "                            <td>" +
        "                             <input required=\"true\" class=\"mini-combobox txk-dict\" style=\"width:150px;\" textField=\"text\" valueField=\"id\" emptyText=\"请选择\" dict=\"CQ_BASE_GEST_RESULT\" showNullItem=\"true\" id='gestResultId-"+index+"' name=\"gestResultId\" /> " +
        "                                </td>\n" +
        "                        </tr>\n" +

        "                        <tr>\n" +
        "                      <td class=\"tabletitle\">月经末时间</td>\n" +
        "                                <td><input required=\"true\" class=\"mini-textbox\" name=\"lastMenses\"/></td>\n" +
        "                            <td class=\"tabletitle\">出生体重</td>\n" +
        "                            <td><input class=\"mini-textbox\" vtype=\"float\" name=\"nbcBw\" />KG</td>\n" +
        // "                            <td class=\"tabletitle\">孕周</td>\n" +
        // "                            <td><input id=\"gestWeeks\" required=\"true\" class=\"mini-textbox mintext\" vtype=\"int\" name=\"gestWeeks\" />W<input id=\"gestDays\" required=\"true\" vtype=\"int\" class=\"mini-textbox mintext\" name=\"gestDays\" />D</td>\n" +
        "                            <td class=\"tabletitle\">出生地点</td>\n" +
        "                            <td><input required=\"true\" class=\"mini-textbox\" name=\"birthPlace\" /></td>\n" +



        "                        </tr>\n" +

        "                        <tr>\n" +
        "                          <td class=\"tabletitle\">出生日期</td>\n" +
        "                            <td><input id=\"nbcBirthday\" class=\"mini-datepicker\" name=\"nbcBirthday\" allowInput=\"false\" onvaluechanged='getGestWeeksNbc'/></td>\n" +
        "                            <td class=\"tabletitle\">出生检查</td>\n" +
        "                            <td><input class=\"mini-textbox\" name=\"birthInspection\" /></td>\n" +
        "                        <td class=\"tabletitle\">出生身长</td>\n" +
        "                               <td><input class=\"mini-textbox\" name=\"nbcLength \" /></td>\n" +

        "                            </tr>\n" +
        "<tr>" +
        "                            <td class=\"tabletitle\">孕周</td>\n" +
        "                            <td><input id=\"gestWeeks\" required=\"true\" class=\"mini-textbox mintext\" vtype=\"int\" name=\"gestWeeks\" />W<input id=\"gestDays\" required=\"true\" vtype=\"int\" class=\"mini-textbox mintext\" name=\"gestDays\" />D</td>\n" +
        "                               <td class=\"tabletitle\">头围</td>\n" +
        "                               <td><input class=\"mini-textbox\" name=\"nbcHeadCircumference\" /></td>\n" +
        "                          <td class=\"tabletitle\">后续治疗</td>\n" +
        "                            <td><input class=\"mini-textbox\" name=\"flupCure\" /></td>\n" +
        //     "                      <td class=\"tabletitle\">月经末时间</td>\n" +
        // "                                <td><input required=\"true\" class=\"mini-textbox\" name=\"lastMenses\"/></td>\n" +

        "</tr>\n" +
        "                        <tr>\n" +
        "                               <td class=\"tabletitle\">1分钟阿氏评分</td>\n" +
        "                               <td><input class=\"mini-textbox\" name=\"oneApgar \" /></td>\n" +

        "                               <td class=\"tabletitle\"> 5分钟阿氏评分</td>\n" +
        "                               <td><input class=\"mini-textbox\" name=\"fiveApgar  \" /></td>\n" +
        "                            <td class=\"tabletitle\">引产日期</td>\n" +
        "                            <td><input id=\"childbirthDate\" class=\"mini-datepicker\" id=\"childbirth\" name=\"childbirthDate\" allowInput=\"false\" onvaluechanged='getGestWeeksChild'/></td>\n" +
        // "                            <td class=\"tabletitle\">出生日期</td>\n" +
        // "                            <td><input id=\"nbcBirthday\" class=\"mini-datepicker\" name=\"nbcBirthday\" allowInput=\"false\" onvaluechanged='getGestWeeksNbc'/></td>\n" +
        // "                            <td class=\"tabletitle\">出生检查</td>\n" +
        // "                            <td><input class=\"mini-textbox\" name=\"birthInspection\" /></td>\n" +



        "                        </tr>\n" +
        "                        <tr>\n" +

        "                            <td class=\"tabletitle\">引产孕周</td>\n" +
        "                            <td><input id=\"inducedGestWeeks\" class=\"mini-textbox mintext\" name=\"inducedGestWeeks\" />W<input class=\"mini-textbox mintext\" name=\"inducedGestDays\" />D</td>\n" +
        "                            <td class=\"tabletitle\">引产特殊情况</td>\n" +
        "                            <td><input class=\"mini-textbox\" name=\"inducedSpecial\" /></td>\n" +

        "                            <td class=\"tabletitle\">引产原因</td>\n" +
        "                            <td><input class=\"mini-combobox txk-dict\" style=\"width:150px;\" textField=\"text\" valueField=\"id\" emptyText=\"请选择\" dict=\"CQ_BASE_INDUCED_CAUSE\" showNullItem=\"true\" id='inducedCauseId-"+index+"'  name=\"inducedCauseId\" /> </td>\n" +

        "                        </tr>\n" +
        "                        <tr>\n" +

        "                            <td class=\"tabletitle\">尸检</td>\n" +
        "                            <td><input class=\"mini-radiobuttonlist\" data=\"[{id: 1, text: '是'}, {id: 2, text: '否'}]\" name=\"isPme\" /></td>\n" +
        "                            <td class=\"tabletitle\">新生儿性别</td>\n" +
        "                            <td><input required=\"true\" class=\"mini-radiobuttonlist\" data=\"[{id: 'm', text: '男'}, {id: 'f', text: '女'}, {id: 'n', text: '不详'}]\" name=\"nbcSex\" /></td>\n" +
        "                         <td class=\"tabletitle\">标本留存</td>\n" +
        "                            <td  style=\"display: flex;\"><input required=\"true\" class=\"mini-radiobuttonlist\"   id=\"isSpecKeep\" style=\"width:150px;\"data=\"[{id: '1', text: '是'}, {id: 2, text: '否'}]\" name=\"isSpecKeep\" onvaluechanged=\"valuechanged\"/>\n" +
        "                                <input class=\"mini-combobox txk-dict\" id='specKeepId' style=\"display:none;width:150px;\" multiSelect='true' width:150px;\" textField=\"text\" valueField=\"id\" emptyText=\"选择留存标本\" dict=\"CQ_BASE_SPEC_KEEP\" showNullItem=\"true\"  name=\"specKeepId\" /> </td></td>\n" +
        "                        </tr>\n" +
        "                        <tr>\n" +
        "                            <td class=\"tabletitle\">资料上传</td>\n" +
        "                            <td ><input type=\"file\" id=\"thisnibaba\" name=\"dibAndDiacModel.dibFiles\" multiple /></td>\n" +
        // "                        </tr>\n" +
        // "                        <tr>\n" +
        "                            <td class=\"tabletitle\">随访备注</td>\n" +
        "                            <td colspan=\"4\"><textarea class=\"mini-textarea\"  style=\"width: 98%;height: 80px;\" name=\"flupRemark\" emptyText=\"\"></textarea></td>\n" +

        "                        </tr>\n" +
        "<tr>\n" +
        "                        <td></td>\n" +
        "                        <td></td>\n" +
        "                        <td><input type=\"button\" class=\"GDBTN\" value=\"资料查询\" onclick=\"onclick4(this)\" /></td>\n" +
        "                    </tr>\n" +
        "                    </table>\n" +
        "                </div>")
    txkui.parse($("#tabs1"),function () {

        var names = mini.getsbyName("patientName");
        for (var i = 0; i < names.length; i++) {
            names[i].setValue(patientName);
        }
        var ids = mini.getsbyName("diacrisisId");
        for (var i = 0; i < ids.length; i++) {
            ids[i].setValue(patientId);
        }

    })

    //active tab
    tabs.activeTab(tab);
    if(callback){

        callback();
    }

}
function testDel() {
    var tabs = mini.get("tabs1");
    var tab = tabs.getActiveTab();
    if (tab) {
        tabs.removeTab(tab);
    }
}